import type {
  SysTenantDtlVo,
  SysTenantPageQo,
  SysTenantQo,
  SysTenantVo,
} from '#/system/tenants/tenants'
import { http } from '@/utils/request/index'

/**
 * 获取租户分页列表
 * @param params 查询参数
 * @returns 租户列表
 */
export function getSysTenantPageListApi(params: SysTenantPageQo) {
  return http.request<PageResult<SysTenantVo>>('get', '/admin-api/system/sysTenant/sysTenantPage', {
    params,
  })
}

/**
 * 获取租户详情
 * @param id 租户id
 * @returns 租户详情
 */
export function getSysTenantDetailsApi(id?: string) {
  return http.request<SysTenantDtlVo>('get', `/admin-api/system/sysTenant/sysTenantDetails/${id}`)
}

/**
 * 新增租户
 * @param data 租户信息
 * @returns 租户id
 */
export function createSysTenantApi(data: SysTenantQo) {
  return http.request<string>('post', '/admin-api/system/sysTenant/sysTenantCreate', {
    data,
  })
}

/**
 * 修改租户
 * @param data 租户信息
 * @returns 租户id
 */
export function updateSysTenantApi(data: SysTenantQo) {
  return http.request<string>('post', '/admin-api/system/sysTenant/sysTenantUpdate', {
    data,
  })
}

/**
 * 删除租户
 * @param idList 租户id列表
 * @returns 租户id
 */
export function deleteSysTenantApi(idList: string[]) {
  return http.request<string>('post', '/admin-api/system/sysTenant/sysTenantRemove', {
    params: {
      idList: idList.join(','),
    },
  })
}

/**
 * 启用租户
 * @param idList 租户id列表
 * @returns 租户id
 */
export function enableSysTenantApi(idList: string[]) {
  return http.request<string>('post', '/admin-api/system/sysTenant/sysTenantEnable', {
    params: {
      idList: idList.join(','),
    },
  })
}

/**
 * 禁用租户
 * @param idList 租户id列表
 * @returns 租户id
 */
export function disableSysTenantApi(idList: string[]) {
  return http.request<string>('post', '/admin-api/system/sysTenant/sysTenantDisable', {
    params: {
      idList: idList.join(','),
    },
  })
}
